﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESOL.Common.Entity;
using System.Data;
using ESOL.Business.Hr;
using System.ServiceModel;
using System.IO;
using ESOL.Business.Mst;

namespace ESOL.Services
{
    [ServiceBehavior(UseSynchronizationContext = false,
    ConcurrencyMode = ConcurrencyMode.Multiple,
    InstanceContextMode = InstanceContextMode.PerCall)]
    public class HrService:IHrService
    {
        public string HellowWord()
        {
            return "Hellow Word!";
        }


        //考勤资料是否导入过，根把文件名，如
        public DTOBool IsImportedAttendance(string fileName)
        {
            DTOBool output = new DTOBool();
            try
            {
               output.result= HrAttendanceRecordBs.IsImport(fileName);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "IsImportedAttendance";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //导入考勤资料
        public DTOString ImportAttendance(DataTable attendance,string fileName)
        {
            DTOString output = new DTOString();
            try
            {
                HrAttendanceRecordBs.ImportAttendance(attendance,fileName);
            }
            catch (Exception ex)
            {
                output.result = "";
                output.ErrorCode = "ImportAttendance";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        //考勤报表
        public DTODataTable GetOverviewByCondition(HrAttendanceRecordEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrAttendanceRecordBs.GetOverviewByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetOverviewByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


       


        ////取考勤记录
        public DTODataTable GetHrAttendanceRecordByCondition(HrAttendanceRecordEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrAttendanceRecordBs.GetHrAttendanceRecordByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrAttendanceRecordByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }



        #region 出差管理
        public DTODataTable GetHrTravleApplicationByCondition(HrTravelApplicationEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrTravelApplicationBs.GetHrTravleApplicationByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrTravleApplicationByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //添加出差申请单
        public DTOBool InsertHrTravelApplication(HrTravelApplicationEntity TravelApplicationEnity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrTravelApplicationBs.InsertHrTravelApplication(TravelApplicationEnity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrTravelApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //修改出差申请单
        public DTOBool UpdateHrTravelApplication(HrTravelApplicationEntity TravelApplicationEnity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrTravelApplicationBs.UpdateHrTravelApplication(TravelApplicationEnity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrTravelApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        //删除出差申请单
        public DTOBool DeleteHrTravelApplication(HrTravelApplicationEntity TravelApplicationEnity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrTravelApplicationBs.DeleteHrTravelApplication(TravelApplicationEnity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrTravelApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion


        #region 部门管理
        public DTODataTable GetDapartmentByCondition(MstDepartmentEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = MstDepartmentBs.GetDapartmentByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetDapartmentByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion

        #region 员工档案

        //新建员工档案
        public DTOBool AddHrEmployee(HrEmployeeEntity employee)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrEmployeeBs.InsertHrEmployee(employee);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrEmployee";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //修改员工档案
        public DTOBool UpdateHrEmployee(HrEmployeeEntity employee)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrEmployeeBs.UpdateHrEmployee(employee);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrEmployee";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //取员工信息
        public DTOHrEmployeeEntity GetEmployeeByNo(HrEmployeeEntity employee)
        {
            DTOHrEmployeeEntity output = new DTOHrEmployeeEntity();
            try
            {
                output.result = HrEmployeeBs.GetHrEmployeeByNo(employee);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetEmployeeByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTODataTable GetEmployeeByCondition(HrEmployeeEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrEmployeeBs.GetHrEmployeeByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetEmployeeByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        //员工图片路径
        public DTOString GetEmployeePhotoPath()
        {
            DTOString output = new DTOString();
            try
            {
                output.result = HrEmployeeBs.EmployeePhotoPath();
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "EmployeePhotoPath";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //上传员工图片
        public DTOString UploadFileNew(byte[] fs, string fileName)
        {
            DTOString output = new DTOString();
            try
            {
                ///定义并实例化一个内存流，以存放提交上来的字节数组。 
                MemoryStream m = new MemoryStream(fs);
                ///定义实际文件对象，保存上载的文件。
                FileStream f = new FileStream(fileName, FileMode.Create);
                m.WriteTo(f);
                m.Close();
                f.Close();
                f = null;
                m = null;
               
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "UploadFileNew";
                output.ErrorMessage = ex.Message;
            }
            return output;
            
            
        }
        

        //下载员工相片
        public DTOByte DownloadFileNew(string fileName)
        {
            DTOByte output = new DTOByte();
            try
            {
                FileInfo fi = new FileInfo(fileName);
                FileStream fs = fi.OpenRead();
                byte[] bytes = new byte[fs.Length];
                fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
                fs.Close();
                output.result = bytes;
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "UploadFileNew";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //获取员工代理人
        public DTOHrAgentEntity GetHrAgentByEmployeeNo(string employeeNo)
        {
            DTOHrAgentEntity output = new DTOHrAgentEntity();
            try
            {
                output.result = HrAgentBs.GetHrAgentByEmployeeNo(employeeNo);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrAgentByEmployeeNo";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        //保存员工档案
        public DTOHrEmployeeEntity SaveHrEmployee(HrEmployeeEntity employee,HrAgentEntity agent, List<HrPersonPositionEntity> listPersonPosition )
        {
            DTOHrEmployeeEntity output = new DTOHrEmployeeEntity();
            try
            {
                output.result = HrEmployeeBs.SaveHrEmployee(employee, agent, listPersonPosition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "SaveHrEmployee";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        //删除员工档案
        public DTOBool DeleteHrEmployee(HrEmployeeEntity employee)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrEmployeeBs.DeleteHrEmployee(employee);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "SaveHrEmployee";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        

        public DTODataTable GetEmployeePositionById(string employeeId)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                DataSet ds = HrPersonPositionBs.GetPersonPositionById(employeeId);
                output.result = ds.Tables[0];
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetEmployeePositionById";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrContractHistory(HrContractHistoryEntity history)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrContractHistoryBs.InsertHrContractHistory(history);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrContractHistory";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool UpdateHrContractHistory(HrContractHistoryEntity history)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrContractHistoryBs.UpdateHrContractHistory(history);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrContractHistory";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrContractHistory(HrContractHistoryEntity history)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrContractHistoryBs.DeleteHrContractHistory(history);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrContractHistory";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool ApproveHrContractHistory(HrContractHistoryEntity history)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrContractHistoryBs.ApproveHrContractHistory(history);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "ApproveHrContractHistory";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTODataTable GetHrContractHistoryByCondition(HrContractHistoryEntity condition, HrEmployeeEntity employeeCondition)
        {

            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrContractHistoryBs.GetHrContractHistoryByCondition(condition,employeeCondition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrContractHistoryByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        
        #endregion


        #region 请假管理

        public DTODataTable GetLeaveApplicationsByCondition(HrLeaveApplicationEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrLeaveApplicationBs.GetLeaveApplicationsByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetLeaveApplicationsByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool DeleteHrLeaveApplication(HrLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrLeaveApplicationBs.DeleteHrLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool InsertHrLeaveApplication(HrLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrLeaveApplicationBs.InsertHrLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrLeaveApplication(HrLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrLeaveApplicationBs.UpdateHrLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion


        #region 补办考勤卡
        public DTODataTable GetCardLossByCondition(DTOHrAttendanceCardLossEntity entity)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrAttendanceCardLossBs.GetCardLossByCondition(entity);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetCardLossByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrAttendanceCardLoss(HrAttendanceCardLossEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrAttendanceCardLossBs.DeleteHrAttendanceCardLoss(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrAttendanceCardLoss";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrAttendanceCardLoss(HrAttendanceCardLossEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrAttendanceCardLossBs.InsertHrAttendanceCardLoss(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrAttendanceCardLoss";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrAttendanceCardLoss(HrAttendanceCardLossEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrAttendanceCardLossBs.UpdateHrAttendanceCardLoss(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrAttendanceCardLoss";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        #endregion



        #region 用车管理
        public DTODataTable GetHrCarRentingByCondition(DTOHrCarRentingEntity entity)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrCarRentingBs.GetHrCarRentingByCondition(entity);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrCarRentingByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrCarRenting(HrCarRentingEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrCarRentingBs.DeleteHrCarRenting(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrCarRenting";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrCarRenting(HrCarRentingEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrCarRentingBs.InsertHrCarRenting(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrCarRenting";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrCarRenting(HrCarRentingEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrCarRentingBs.UpdateHrCarRenting(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrCarRenting";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion

        #region 转正管理
        public DTODataTable GetHrFormalApplicationByCondition(HrFormalApplicationEntity entity, string rowCount)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrFormalApplicationBs.GetByCondition(entity, rowCount);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrCarRentingByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrFormalApplication(HrFormalApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrFormalApplicationBs.DeleteHrFormalApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrFormalApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrFormalApplication(HrFormalApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrFormalApplicationBs.InsertHrFormalApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrFormalApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrFormalApplication(HrFormalApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrFormalApplicationBs.UpdateHrFormalApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrFormalApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool ApproveHrFormalApplication(HrFormalApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrFormalApplicationBs.ApproveHrFormalApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "ApproveHrFormalApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        
        #endregion



        #region 离职管理


        public DTODataTable GetHrEmployeeLeaveApplicationByCondition(HrPersonLeaveApplicationEntity entity, string rowCount)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrPersonLeaveApplicationBs.GetEmployeeLeaveByCondition(entity, rowCount);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrEmployeeLeaveApplicationByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrEmployeeLeaveApplication(HrPersonLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonLeaveApplicationBs.DeleteHrPersonLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrEmployeeLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrEmployeeLeaveApplication(HrPersonLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonLeaveApplicationBs.InsertHrPersonLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrEmployeeLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrEmployeeLeaveApplication(HrPersonLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonLeaveApplicationBs.UpdateHrPersonLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrEmployeeLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool ApproveHrEmployeeLeaveApplication(HrPersonLeaveApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonLeaveApplicationBs.ApproveHrPersonLeaveApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "ApproveHrEmployeeLeaveApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion


        #region 调职管理
        public DTODataTable GetHrPersonPositionApplicationByCondition(HrPersonPositionApplicationEntity entity, string rowCount)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrPersonPositionApplicationBs.GetPositionChangeReqByCondition(entity, rowCount);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrPersonPositionApplicationByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrPersonPositionApplication(HrPersonPositionApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonPositionApplicationBs.DeleteHrPersonPositionApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrPersonPositionApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrPersonPositionApplication(HrPersonPositionApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonPositionApplicationBs.InsertHrPersonPositionApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrPersonPositionApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrPersonPositionApplication(HrPersonPositionApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonPositionApplicationBs.UpdateHrPersonPositionApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrPersonPositionApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool ApprovePersonPositionApplication(HrPersonPositionApplicationEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrPersonPositionApplicationBs.ApprovePersonPositionApplication(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "ApprovePersonPositionApplication";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion

        #region 调薪管理

        public DTODataTable GetHrSalaryChangeByCondition(HrSalaryChangeEntity condition)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrSalaryChangeBs.GetHrSalaryChangeByCondition(condition);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrSalaryChangeByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrSalaryChange(HrSalaryChangeEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrSalaryChangeBs.DeleteHrSalaryChange(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrSalaryChange";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrSalaryChange(HrSalaryChangeEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrSalaryChangeBs.InsertHrSalaryChange(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrSalaryChange";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrSalaryChange(HrSalaryChangeEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrSalaryChangeBs.UpdateHrSalaryChange(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrSalaryChange";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool ApproveHrSalaryChange(HrSalaryChangeEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrSalaryChangeBs.ApproveHrSalaryChange(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "ApproveHrSalaryChange";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        #endregion


        #region 出门证
        public DTODataTable GetHrEmployeeIoRecordByCondition(DTOHrEmployeeIoRecordEntity entity)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrEmployeeIoRecordBs.GetHrEmployeeIoRecordByCondition(entity);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrEmployeeIoRecordByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrEmployeeIoRecord(HrEmployeeIoRecordEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrEmployeeIoRecordBs.DeleteHrEmployeeIoRecord(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrEmployeeIORecord";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrEmployeeIoRecord(HrEmployeeIoRecordEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                if (string.IsNullOrEmpty(entity.ReqNo))
                    entity.ReqNo = MstCodeRuleBs.GetCurrentOrderCode("EIORequest");
                if (string.IsNullOrEmpty(entity.ReqNo))
                {
                    output.result = false;
                    output.ErrorCode = "InsertHrEmployeeIoRecord";
                    output.ErrorMessage = "申请单号为空";
                    return output;
                }
                output.result = HrEmployeeIoRecordBs.InsertHrEmployeeIoRecord(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrEmployeeIoRecord";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrEmployeeIoRecord(HrEmployeeIoRecordEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrEmployeeIoRecordBs.UpdateHrEmployeeIoRecord(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrEmployeeIoRecord";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        #endregion


        #region 工资管理
        public DTODataTable GetHrMonthSalaryByCondition(HrMonthSalaryEntity salaryCondition, HrEmployeeEntity employeeCondition, string month)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrMonthSalaryBs.GetHrMonthSalaryByCondition(salaryCondition, employeeCondition,month);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrMonthlySalaryByCondition";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTODataTable GetHrMonthSalaryItemDetail(string salaryId)
        {
            DTODataTable output = new DTODataTable();
            try
            {
                output.result = HrMonthSalaryItemBs.GetHrMonthSalaryItem(salaryId);
            }
            catch (Exception ex)
            {
                output.result = null;
                output.ErrorCode = "GetHrMonthSalaryItemDetail";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool DeleteHrMonthlySalary(HrMonthSalaryEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrMonthSalaryBs.DeleteHrMonthSalary(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "DeleteHrMonthlySalary";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool InsertHrMonthSalary(HrMonthSalaryEntity entity, List<HrMonthSalaryItemEntity> salaryItems)
        {
            DTOBool output = new DTOBool();
            try
            {

                output.result = HrMonthSalaryBs.InsertHrMonthSalary(entity, salaryItems);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "InsertHrMonthSalary";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool UpdateHrMonthSalary(HrMonthSalaryEntity entity, List<HrMonthSalaryItemEntity> salaryItems)
        {
            DTOBool output = new DTOBool();
            try
            {
                output.result = HrMonthSalaryBs.UpdateHrMonthSalary (entity, salaryItems);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "UpdateHrMonthSalary";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }


        public DTOBool SubmitHrMonthSalary(string salaryMonth)
        {
            DTOBool output = new DTOBool();
            try
            {

                output.result = HrMonthSalaryBs.SubmitHrMonthSalary(salaryMonth);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "SubmitHrMonthSalary";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }

        public DTOBool ApproveHrMonthSalary(HrMonthSalaryEntity entity)
        {
            DTOBool output = new DTOBool();
            try
            {

                output.result = HrMonthSalaryBs.ApproveHrMonthSalary(entity);
            }
            catch (Exception ex)
            {
                output.result = false;
                output.ErrorCode = "SubmitHrMonthSalary";
                output.ErrorMessage = ex.Message;
            }
            return output;
        }
        #endregion
    }
}
